<template>
    <div class=" banner1">

        <div class="date">{{ month }}</div>
    </div>
</template>

<script>

export default {
    name: "monthlyReport",  //月度统计报告
    components: {
    },
    props: {
        month: {
            type: String,
            // required: true,
        }
    },
    data() {
        return {
            date: null,
        };
    },
    watch: {
        month(val) {
            console.log('month', val);
        }
    },
    mounted() {

    },
    created() {
        this.getDate()
    },
    methods: {
        getDate() {
            // 创建一个新的Date对象
            const currentDate = new Date();

            // 获取当前的年份（四位数字）
            const currentYear = currentDate.getFullYear();

            // 获取当前的月份（0-11），并加1以转换为常见的1-12格式
            const currentMonth = currentDate.getMonth() + 1;
            // 获取当前日期中的日
            // const currentDay = currentDate.getDate();
            let year, month;

            // 注意：如果当前是1月，则上个月是上一年的12月
            if (currentMonth === 1) {
                year = currentYear - 1;
                month = 12;
            } else {
                year = currentYear;
                month = currentMonth - 1;
            }
            const formattedMonth = month.toString();
            // 使用字符串的padStart方法确保月份是两位数

            // 拼接年份和月份，并以"YYYY-MM"格式输出
            this.date = `${year}-${formattedMonth}`;

        }
    }
};
</script>


<style lang="scss" scoped>
.banner1 {
    background: url(../../../assets/banner1.png) no-repeat 0 0/cover;
    height: 100%;
}


.datePicker {
    // border: 1px solid red;
    position: fixed;
    top: 210px;
    left: 94px;
}

.date {
    width: 100%;
    height: 100%;
    font-size: 100px;
    padding-top: 274px;
    margin-left: 94px;
    color: white;
    text-shadow: 6px -6px #5d1b1d;
    letter-spacing: 36px;
    text-align: left;
    font-family: "微软雅黑";
    font-weight: 900;
}
</style>